<?php

namespace app\adminapi\controller\v1\portal;

use app\adminapi\controller\AuthController;
use app\services\portal\PortalInformService;
use think\facade\App;

/**
 * 门户网站信息发布
 */
class PortalInform extends AuthController
{
    public function __construct(App $app, PortalInformService $service)
    {
        parent::__construct($app);
        $this->services = $service;
    }


    public function index(){
        $where = $this->request->postMore([
            ['page', 1],
            ['pageSize', 20],
            ['website_id',$this  -> website],
        ]);
        return app() -> make('json') -> successful($this -> services -> index($where));
    }
    public function create(){
        $where = $this->request->postMore([
            ['website_id', $this -> website],
            ['title', ''],
            ['content',''],
            ['coverImg',''],
            ['type',''],
            ['isSlideshow',''],
        ]);
        return app() -> make('json') -> successful($this -> services -> create($where));
    }
    public function update(){
        $where = $this->request->postMore([
            ['title', ''],
            ['id', ''],
            ['content',''],
            ['coverImg',''],
            ['type',''],
            ['isSlideshow',''],
        ]);
        return app() -> make('json') -> successful($this -> services -> update($where));
    }

    public function delete(){
        $where = $this->request->postMore([
            ['id', '']
        ]);
        return app() -> make('json') -> successful($this -> services -> delete($where));
    }

    public function searchTitle(){
        $where = $this->request->postMore([
            ['title', ''],
            ['isSlideshow', ''],
            ['type', ''],
            ['page', 1],
            ['pageSize', 20],
            ['website_id', $this -> website]
        ]);
        return app() -> make('json') -> successful($this -> services -> searchTitle($where));
    }


}